<template>
  <div>
    <City-Header></City-Header>
    <City-Search :cities="cities"></City-Search>
    <City-List
      :cities="cities"
      :hotCities="hotCities"
      :letter="letter"
    ></City-List>
    <City-Aiphabet :cities="cities" @change="handleLetterChange">
    </City-Aiphabet>
  </div>
</template>

<script>
import CityHeader from "./components/Herder";
import CitySearch from "./components/search";
import CityList from "./components/List";
import CityAiphabet from "./components/Aiphabet";
import axios from "axios";
export default {
  name: "City",
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAiphabet,
  },
  data() {
    return {
      cities: {},
      hotCities: [],
      letter: "",
    };
  },
  methods: {
    getCityInfon() {
      axios.get("/api/city.json").then(this.getCityInfoSucc);
    },
    getCityInfoSucc(res) {
      res = res.data;
      if (res.ret && res.data) {
        const data = res.data;
        this.cities = data.cities;
        this.hotCities = data.hotCities;
      }
    },
    handleLetterChange(letter) {
      this.letter = letter;
    },
  },
  mounted() {
    this.getCityInfon();
  },
};
</script>

<style lang="stylus" scoped></style>>